/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package network.rmi;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.server.UnicastRemoteObject;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author anh_yeu_em_nhieu_lam
 */
public class Server extends UnicastRemoteObject implements InterfaceMessage {
    //Đăng ký server sử dụng Rmi
    public Server() throws RemoteException {
        try {
            LocateRegistry.createRegistry(1099);
            Naming.rebind("Message", this);//Với tên đăng ký là Message
        } catch (MalformedURLException ex) {
            Logger.getLogger(Server.class.getName()).log(Level.SEVERE, null, ex);
        }
    }   
    public String sendMessage(String mes) {
        System.out.print("Nhan duoc message : "+mes);
        return "Send to client : " + mes;
    }
    public static void main(String args[]){
        try {
            Server server = new Server();
        } catch (RemoteException ex) {
            Logger.getLogger(Server.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
